import { request } from 'umi';

// 根据手机号查询用户
export async function getUserByMobile(params = {}) {
  return request(`${window.API_BASE_URL}/admin/user/query`, {
    method: 'GET',
    params,
  });
}
// 获取用户列表
export async function getUserList(params = {}) {
  return request(`${window.API_BASE_URL}/admin/user/list`, {
    method: 'GET',
    params,
  });
}

// 创建用户
export async function createUser(data) {
  return request(`${window.API_BASE_URL}/admin/user`, {
    method: 'POST',
    data,
  });
}

// 获取用户详情
export async function getUserDetail(id) {
  return request(`${window.API_BASE_URL}/admin/user/${id}`, {
    method: 'GET',
  });
}

// 更新用户余额
export async function updateUserBalance(id, data) {
  return request(`${window.API_BASE_URL}/admin/user/${id}/balance`, {
    method: 'PUT',
    data,
  });
}

// 更新用户积分
export async function updateUserCredit(id, data) {
  return request(`${window.API_BASE_URL}/admin/user/${id}/credit`, {
    method: 'PUT',
    data,
  });
}

// 获取用户余额变动记录
export async function getUserBalanceRecord(id) {
  return request(`${window.API_BASE_URL}/admin/user/${id}/balance/record`, {
    method: 'GET',
  });
}

// 获取用户积分变动记录
export async function getUserCreditRecord(id) {
  return request(`${window.API_BASE_URL}/admin/user/${id}/credit/record`, {
    method: 'GET',
  });
}
